package com.zaimokuza.cn.service.schedule;

import com.zaimokuza.cn.service.StatisticsService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDate;

/**
 * 统计相关定时任务
 * <p>
 * 每隔一分钟执行一次的corn表达式：" 0 *|1 * * * ? "
 *
 * @author zaimokuza
 */
@Service
public class StatisticsScheduleService {

    @Resource
    private StatisticsService statisticsService;

    /**
     * 每天00:05:00统计用户相关统计数据
     */
    @Scheduled(cron = "0 5 0 * * ?")
    public void generateUserStatistics() {
        statisticsService.statisticUserData(LocalDate.now().minusDays(1).toString());
    }

    /**
     * 每天00:05:00统计网站相关数据
     */
    @Scheduled(cron = "0 5 0 * * ?")
    public void generateStatistics() {
        statisticsService.statisticManageData(LocalDate.now().minusDays(1).toString());
    }

}
